package com.weidft.dal.plan.dao.ibatis;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.weidft.dal.plan.dao.IWeekEndDAO;
import com.weidft.dal.plan.dataobject.WeekEndDO;

public class IBatisWeekEndDAO extends SqlMapClientDaoSupport implements
		IWeekEndDAO {

	@Override
	public Integer insert(WeekEndDO record) {
		Object newKey = getSqlMapClientTemplate().insert(
				"PLAN_WEEKEND.insert_weekend", record);
		return (Integer) newKey;
	}

	@Override
	public int delete(int year, int month) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("year", year);
		paramMap.put("month", month);

		int rows = getSqlMapClientTemplate().delete(
				"PLAN_WEEKEND.delete_Weekend", paramMap);
		return rows;
	}

	@Override
	public List<WeekEndDO> getWeekEndByYearAndMonth(int year, int month) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("year", year);
		paramMap.put("month", month);

		return getSqlMapClientTemplate().queryForList(
				"PLAN_WEEKEND.getWeekEndByYearAndMonth", paramMap);
	}

	@Override
	public List<WeekEndDO> getWeekListByDateInterval(Map<String, Date> map) {
		return getSqlMapClientTemplate().queryForList(
				"PLAN_WEEKEND.getWeekListByDateInterval", map);
	}

}
